﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.IO;
using Newtonsoft.Json.Linq;

namespace Biosek
{
	public static class JsonSerializerHelper
	{
		public static void SaveJsonFile(this object obj, string filename)
		{
			var ser = new JsonSerializer();
			ser.Formatting = Formatting.Indented;
			using (var file = new StreamWriter(filename))
			{
				ser.Serialize(file, obj);
			}
		}

		public static object LoadJsonFile(string filename)
		{
			var ser = new JsonSerializer();
			using (var file = new StreamReader(filename))
			using (var reader = new JsonTextReader(file))
			{
				return ser.Deserialize(reader);
			}
		}
	}
}
